package com.fastwire.carriere.controller.impl;

import java.util.List;

import com.fastwire.carriere.controller.DiscoveryController;
import com.fastwire.carriere.dao.DAOException;
import com.fastwire.carriere.dao.DAOFactory;
import com.fastwire.carriere.dao.DiscoveryRecordDao;
import com.fastwire.carriere.discovery.entity.DiscoveryRecord;
import com.fastwire.carriere.discovery.vo.DiscoveryRecordVo;
import com.google.common.collect.Lists;

public class DiscoveryControllerImpl implements DiscoveryController {

	private final DiscoveryRecordDao discoveryRecordDao = DAOFactory
			.getInstance().getDiscoveryRecordDao();

	@Override
	public List<DiscoveryRecordVo> searchDiscoveryRecord(
			DiscoveryRecordVo discoveryRecordVo) throws DAOException {

		List<DiscoveryRecord> discoveryRecords = discoveryRecordDao
				.findDiscoveryRecordbySearchCriteria(discoveryRecordVo);

		List<DiscoveryRecordVo> discoveryRecordVos = Lists.newArrayList();
		if (discoveryRecords != null) {

			for (DiscoveryRecord discoveryRecord : discoveryRecords) {
				discoveryRecordVos.add(new DiscoveryRecordVo(discoveryRecord));
			}
		}

		return discoveryRecordVos;

	}
}
